import java.util.*;

// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main4 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int []a = new int[n];
        int []b = new int[n];
        int []c = new int[n];
        for (int i = 0; i <n; i++) {
            a[i]=scan.nextInt();
        }
        for (int i = 0; i <n; i++) {
            b[i]=scan.nextInt();
        }
        for (int i = 0; i <n; i++) {
            c[i]=scan.nextInt();
        }
        long ans=0;
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        //没要求列出所有的i，j，k ，不用担心i，j，k排序后顺序乱了，所以可以排序，节约时间
        int p = 0; //a小于b的指针
        int q = 0;//c大于b的指针
        //注意中间量b
        for (int i = 0; i < n ; i++) {
            while(p<n&&a[p]<b[i]){p++;}
            while(q<n&&c[q]<=b[i]){q++;}
            ans+=((long)p*(n-q));
        }

        System.out.println(ans);

        scan.close();
    }
}